package com.nbsaas.boot.pay.rest.convert;

import com.nbsaas.boot.pay.data.entity.PayOrder;
import com.nbsaas.boot.pay.api.domain.request.PayOrderRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.pay.data.entity.PayUser;

/**
* 付款订单请求对象转换成实体对象
*/

public class PayOrderEntityConvert  implements Converter<PayOrder, PayOrderRequest> {

    @Override
    public PayOrder convert(PayOrderRequest source) {
        PayOrder result = new PayOrder();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getUser()!=null){
                    PayUser user =new PayUser();
                    user.setId(source.getUser());
                    result.setUser(user);
                    }
        return result;
    }
}

